package com.gwt.client.util.geo;



public class UserLocation {

	public interface UserLocationCallback {
		public void onLocationFound(Coordinates coords);
	}

	protected static final void handleSuccess(UserLocationCallback callback, Position position){
		Coordinates coords = position.getCoords();
		callback.onLocationFound(coords);
	}
	
	public static native boolean isSupported() /*-{
		return $wnd.navigator.geolocation != null;
	}-*/;
	
	public static native void getLocation(UserLocationCallback callback) /*-{
		$wnd.navigator.geolocation.getCurrentPosition(function(position){
			@com.gwt.client.util.geo.UserLocation::handleSuccess(Lcom/gwt/client/util/geo/UserLocation$UserLocationCallback;Lcom/gwt/client/util/geo/Position;)(callback, position);
		});
	}-*/;

}